﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.IO;
using System.Web.Core;

namespace Yuanlin.Business
{
    public class EditIntroduction : YuanlinUserControl
    {
        protected ValuedEditor descriptionValuedEditor;

        protected IButton SaveButton;
        private YuanlinUser user = null;

        public EditIntroduction()
            : base()
        {
            user = HttpContext.Current.User as YuanlinUser;
            if (user.IsAnonymous)
            {
                Context.Response.Redirect(SiteUrls.Instance().Login);
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Bind();
            }
            SaveButton.Click += new EventHandler(SaveButton_Click);
        }
        private void Bind()
        {
            this.descriptionValuedEditor.Value = user.CompanyDescription.Value;
        }
        public void SaveButton_Click(object sender, EventArgs e)
        {
            user.CompanyDescription.Value = this.descriptionValuedEditor.Value;

            UserManager.UpdateUser(user);

            Globals.ShowMessage(this.Page, "EditIntroduction", "保存成功!");
        }
    }
}